﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StudentSystem
{
    public class Login_Interface
    {
        public StudentSystem StudentSystem;

        public Login_Interface(StudentSystem ss)
        {
            StudentSystem = ss;
        }
        

        public static void LoginPanel()//进入系统
        {
            Drawing.LoginInterface();
            int enterNumber;
            

            bool flag = false;
            do
            {
                if (flag)
                {
                    Console.Write("输入错误，请重新输入需要操作的编号:");
                }
                else
                {
                    Console.Write("请输入需要操作的编号:");
                }
                flag = false;
                while (!int.TryParse(Console.ReadLine(),out enterNumber))
                {
                    Console.Write("\n输入错误，请重新输入:");
                }

                switch (enterNumber)
            {
                case 1:InputAccountPassword()
                    ; break;
                case 2: Environment.Exit(0)
                    ; break;
                default:
                    flag = true;
                    break;
            }
            } while (flag);
        }

        public  static void InputAccountPassword()//输入账号密码
        {
            bool flag = false;
            do
            {
                if (flag)
                {
                    Console.Write("账号或密码错误，请重新输入账号:");
                }
                else
                {
                    Console.Write("请输入账号:");
                }
                flag = false;
                string account = Console.ReadLine();
                Console.Write("\n请输入密码:");
                string password = Console.ReadLine();

                if (checkAccountPassowrd(account,password))
                {
                    landingRole();
                    return;
                }
                flag = true;
            } while (flag);
        }

        public static bool checkAccountPassowrd(string a, string b)//判断密码对错
        {
            if (a == "11111" && b == "2222")
            {
                return true;
            }
                return false;
        }

        public  static void landingRole()//学生、老师角色选择
        {
            Drawing.landingRole();
            int enterNumber;
            
            bool flage = false;
            do
            {
                if (flage)
                {
                    Console.Write("输入错误，请重新输入需要操作的编号:");
                }
                else
                {
                    Console.Write("请输入操作数字：");
                }
                flage = false;
                while (!int.TryParse(Console.ReadLine(),out enterNumber))
                {
                    Console.Write("\n输入错误，请重新输入:");
                }
                
                switch (enterNumber)
                {
                    case 1: Student.queryInformation()
                         ; break;
                    case 2: Teather.TeatherSystem();break;
                    case 3: LoginPanel();break;
                    case 4: Environment.Exit(0)
                        ; break;
                    default:
                        flage = true;
                        break;
                }
            } while (flage);
        }

    }
}
